
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第2节: http_auth_basic_module · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="http_access_module.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Chapter1/">
            
                <a href="../Chapter1/">
            
                    
                    第一章
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Chapter1/nginx安装.html">
            
                <a href="../Chapter1/nginx安装.html">
            
                    
                    第1节：nginx安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    第二章 nginx模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="http_access_module.html">
            
                <a href="http_access_module.html">
            
                    
                    第1节: http_access_module
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="http_auth_basic_module.html">
            
                <a href="http_auth_basic_module.html">
            
                    
                    第2节: http_auth_basic_module
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第2节: http_auth_basic_module</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;2&#x8282;-httpauthbasicmodule">&#x7B2C;2&#x8282;: http_auth_basic_module</h1>
<blockquote>
<p>Syntax:<code>auth_basic string | off;</code></p>
<p>Default:<code>auth_basic off;</code></p>
<p>Context:<code>http,server,location,limit_except</code></p>
<p>Syntax:<code>auth_basic_user_file file;</code></p>
<p>Default:<code>-</code></p>
<p>Context:<code>http,server,location,limit_except</code></p>
</blockquote>
<p>&#x9996;&#x5148;&#x751F;&#x6210;&#x5BC6;&#x7801;&#x6587;&#x4EF6;</p>
<p><code>htpasswd -c ./auth_conf username</code></p>
<pre><code class="lang-nginx"><span class="hljs-attribute">location</span> <span class="hljs-regexp">~ ^/admin.html</span>{

    <span class="hljs-attribute">root</span> /www/html;

    <span class="hljs-attribute">auth_basic</span> <span class="hljs-string">&quot;Auth access test,Input you password&quot;</span>;

    <span class="hljs-attribute">auth_basic_user_file</span> /etc/auth_conf;

    <span class="hljs-attribute">index</span> index.html index.htm;

}
</code></pre>
<p>&#x5C40;&#x9650;&#x6027;</p>
<p>&#x89E3;&#x51B3;&#x65B9;&#x6848;</p>
<ul>
<li><p>Nginx&#x7ED3;&#x5408;LUA&#x662F;&#x7231;&#x4F60;&#x9AD8;&#x6548;&#x9A8C;&#x8BC1;</p>
</li>
<li><p>Nginx&#x548C;LDAP&#x6253;&#x901A;&#xFF0C;&#x5229;&#x7528;<code>nginx-auth-ldap</code>&#x6A21;&#x5757;</p>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="http_access_module.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 第1节: http_access_module">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第2节: http_auth_basic_module","level":"1.3.2","depth":2,"previous":{"title":"第1节: http_access_module","level":"1.3.1","depth":2,"path":"Chapter2/http_access_module.md","ref":"Chapter2/http_access_module.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Chapter2/http_auth_basic_module.md","mtime":"2018-12-27T14:34:50.526Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-12-27T14:48:52.325Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

